import { defineStore } from 'pinia'
import { ref } from 'vue'
import { getUserInfo } from '@/utils/auth'
export const useUserInfoStore = defineStore('userInfo', () => {
  let loginStatus = getUserInfo() ? ref(true) : ref(false)
  let userInfo = ref({}) || getUserInfo()
  function setUserInfo(value: object) {
    userInfo.value = value
    loginStatus.value = true
  }
  function logout() {
    userInfo.value = {}
    loginStatus.value = false
  }
  return {
    loginStatus,
    userInfo,
    setUserInfo,
    logout
  }
})
